<template>
  <main class="readmission">
    <c-navigation>
      <c-time @change="timeChangeHandler"/>
    </c-navigation>
    <c-card :title="`不合理入院统计的是检查化验占比＞70%，共${pagination.total}条`">
      <a-table class="custom"
               @change="tableChangeHandler"
               :columns="tableColumns"
               :data-source="tableData"
               :pagination="pagination"
               :rowKey="()=>Math.random()"/>
    </c-card>
  </main>
</template>

<script lang="ts">
import columns from "./assets/columns";
import {unreasonableInHospitalList} from "@/api/drgsGroupResults";

export default {
  data() {
    return {
      tableData: [],
      tableColumns: columns,
      timeParams: {},
      pagination: {
        current: 1,
        pageSize: 10,
        total: 0
      }
    }
  },
  computed: {

  },
  methods: {
    timeChangeHandler(e) {
      this.timeParams = e;
      this.pagination.current = 1;
      this.getData();
    },
    tableChangeHandler(e) {
      this.pagination = e;
      this.getData();
    },
    getData() {
      this.getUnreasonableInHospitalList();
    },
    async getUnreasonableInHospitalList() {
      const params = {
        year: this.timeParams.year,
        month: this.timeParams.month,
        pageSize: this.pagination.pageSize,
        pageNum: this.pagination.current,
      }
      this.tableData = [];
      const res = await unreasonableInHospitalList(params);
      if (res['data'] && res['data']['list']) {
        this.tableData = res['data']['list'];
      }
      this.pagination.total = res['data']['total'];
    }
  }
}
</script>

<style scoped lang="stylus">
.readmission {

}
</style>
